<template>
	<view class="page">
		<view class="title">
			{{info.noticeTitle}}
		</view>
		<view class="time">{{info.createTime}}</view>
		<view class="content">
		<rich-text :nodes="content"></rich-text>
		</view>
	</view>
</template>

<script>
	import {noticeInfoAPI,noticelistAPI} from "@/api/appointment.js"
	
	export default {
		data() {
			return {
				info:{},
				id:'',
				content:"",
				type:"1"
			}
		},
		onLoad(option) {
			
			if(option.type==1 || option.type==4){
				// 下单须知
				this.noticelist(option.type)
				uni.setNavigationBarTitle({
					title:option.title	
				})
			}else{
				this.id=option.id || 1
				this.getdata()
			}
			
		},
		methods: {
			noticelist(type){
				noticelistAPI({
					 "pageNo": 1,
					  "pageSize": 1, 
					  "sourceType": 0,
					 type
					  
				}).then(rest=>{
					let res=rest.data[0]
					this.info=res
					 if(res.noticeContent){
						 this.content=res.noticeContent.replace(/\<img/gi, '<img style="display:block; margin:0 auto; width:100%;" ');

					 }
				})
			},
			getdata(){
				noticeInfoAPI({id:this.id}).then(res=>{
					this.info=res.data
					 
					this.content=res.data.noticeContent.replace(/\<img/gi, '<img style="display:block; margin:0 auto; width:100%;" ');
				})
			}
		}
	}
</script>

<style scoped lang="scss">
.page{
	padding: 20rpx;
}
.title{
	font-size: 32rpx;
	font-weight: bold;
	text-align: center;
	line-height: 45rpx;
}
.time{
	color: #7C8191;
	font-size: 22rpx;
	text-align: center;
	margin-top: 10rpx;
}
.content{
	line-height: 40rpx;
	margin-top: 20rpx;
	image{
		width: 100% !important;
	}
}
</style>
